package com._reflect;

import java.lang.annotation.Annotation;

/**
 * @Author: huangya
 * @Date: 2019/11/9
 * @Description:
 *
 * 【根据注解类型获得注解，包含父类】
 * <T extends Annotation> T getAnnotation(Class<T> annotationClass);
 * 【获得所有注解，包含父类】
 * Annotation[] getAnnotations();
 * 【根据注解类型获得注解，包含父类】【配合@Repeatable注解】
 * <T extends Annotation> T[] getAnnotationsByType(Class<T> annotationClass);
 * 【11111】
 * <T extends Annotation> T getDeclaredAnnotation(Class<T> annotationClass);
 * 【11111】
 * Annotation[] getDeclaredAnnotations();
 * 【11111】
 * <T extends Annotation> T[] getDeclaredAnnotationsByType(Class<T> annotationClass);
 * 【11111】
 * boolean isAnnotationPresent(Class<? extends Annotation> annotationClass);
 */
public class _AnnotatedElementDemo {

    public static void main(String[] args) {
        AAA aaa = new AAA();
        InheritedFilterPath annotation = aaa.getClass().getAnnotation(InheritedFilterPath.class);
        System.out.println(annotation);
        Annotation[] annotations = aaa.getClass().getAnnotations();
        System.out.println(annotations);
        InheritedFilterPath[] annotationsByType = aaa.getClass().getAnnotationsByType(InheritedFilterPath.class);
        System.out.println(annotationsByType);

        FilterPath declaredAnnotation = aaa.getClass().getDeclaredAnnotation(FilterPath.class);
        System.out.println(declaredAnnotation);
        Annotation[] declaredAnnotations = aaa.getClass().getDeclaredAnnotations();
        System.out.println(declaredAnnotations);
        FilterPath[] declaredAnnotationsByType = aaa.getClass().getDeclaredAnnotationsByType(FilterPath.class);
        System.out.println(declaredAnnotationsByType);


        boolean annotationPresent = aaa.getClass().isAnnotationPresent(InheritedAnnoClass.class);
        System.out.println(annotationPresent);
        boolean filterPathPresent = aaa.getClass().isAnnotationPresent(FilterPath.class);
        System.out.println(filterPathPresent);
        boolean filterPathsPresent = aaa.getClass().isAnnotationPresent(FilterPaths.class);
        System.out.println(filterPathsPresent);
    }
}
